package com.gxa.web_admin.controller.propertycontroller;

import com.gxa.common.R;
import com.gxa.modules.pojo.Guards;
import com.gxa.modules.service.propertyservice.CarBarrierService;
import com.gxa.modules.service.propertyservice.EquipmentService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0
 * @Author fluoxetine
 * @Date 2022/4/30 23:57
 **/
@RestController
@RequestMapping("/CarBarrier/Intelligent")
@Api(value = "车辆匝道管理",tags = "车辆查询查询接口API")
@RequiresPermissions("车辆管理")
public class CarBarrierController {



    @Autowired
    private CarBarrierService carBarrierService;

    @GetMapping(value = "/selectGuards")
    @ApiOperation(value = "查询接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "device_name",value = "根据设备名称查询", required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "device_id",value = "根据设备编号查询", required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "guards_type",value = "每页显示条数", required = false,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 400,message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R selectGuards(@RequestParam int page,
                          @RequestParam int size,
                          String device_name,String device_id,String guards_type)
    {
        return  carBarrierService.selectGuards(page,size,device_name,device_id,guards_type);
    }


    @PostMapping("/addGuards")
    @ApiOperation(value = "添加接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "POST",response = R.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 400,message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R addGuards(@RequestBody Guards guards)
    {
        return carBarrierService.addGuards(guards);
    }

    @PostMapping(value = "/updateGuardsType")
    @ApiOperation(value = "修改状态", notes = "提供当前页码数与每页显示条数", httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "GuardsTypeId", value = "设备状态", required = true, dataType = "int", paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务器错误")
    })
    public R updateGuardsType(@RequestParam int  GuardsTypeId,
                              @RequestParam int id) {
        return carBarrierService.updateGuardsType(GuardsTypeId,id);
    }

    @PostMapping("/deleteGuardsById")
    @ApiOperation(value = "删除接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "POST",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "根据此条件查询设备信息",required = true,dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 400,message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R deleteGuardsById(String id)
    {
        return carBarrierService.deleteGuardsById(id);
    }


    /**
     * 删除
     */
    @PostMapping("/batchDelete")
    @ApiOperation(value = "批量删除接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "POST",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gpId",value = "批量删除访客信息",required = true,dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 400,message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public void batchDelete(@RequestParam(value = "gpId") String gpId) {
        String[] gpIds = gpId.split(",");
        List<Integer> list = new ArrayList<>();
        for(String str:gpIds){
            list.add(Integer.parseInt(str));
        }
        carBarrierService.batchDelete(list);
    }


    @GetMapping("/selectGuards_alarm")
    @ApiOperation(value = "查询报警接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "device_name",value = "根据设备名称查询", required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "device_id",value = "根据设备编号查询", required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "guards_alarm_type",value = "根据设备状态查询", required = false,dataType = "String",paramType = "query")

    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 400,message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R selectGuards_alarm(@RequestParam int page,
                                @RequestParam int size,
                                String device_name,String device_id,String guards_alarm_type)
    {
        return  carBarrierService.selectGuards_alarm(page,size,device_name,device_id,guards_alarm_type);
    }

    @PostMapping("/deleteGuards_alarmById")
    @ApiOperation(value = "删除报警接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "POST",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "根据此条件查询设备信息",required = true,dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 400,message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R deleteGuards_alarmById(String id)
    {
        return carBarrierService.deleteGuards_alarmById(id);
    }



    @GetMapping("/selectGuards_patrol")
    @ApiOperation(value = "查询巡查接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "device_name",value = "根据设备名字查询",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "device_id",value = "根据设备编号查询",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "patrol_type",value = "根据设备状态查询", required = false,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 400,message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R selectGuards_patrol(@RequestParam int page,
                                 @RequestParam int size,
                                 String device_name,String device_id,String patrol_type)
    {
        return  carBarrierService.selectGuards_patrol(page,size,device_name,device_id,patrol_type);
    }

    @PostMapping("/deleteGuards_patrolById")
    @ApiOperation(value = "删除运维接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "POST",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "根据此条件查询设备信息",required = true,dataType = "String",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 400,message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    public R deleteGuards_patrolById(String id)
    {
        return carBarrierService.deleteGuards_patrolById(id);
    }


}